package phase01module02.homework;

/**
 * 用户消费类
 * 1.统计通话时长
 * 2.统计上网流量
 * 3.每月消费金额
 */
public class Bill {
    private int teleTime; //通话时长
    private int surfFlow; //上网流量
    private int expenses; //消费金额

    public Bill() {
    }

    public Bill(int teleTime, int surfFlow, int expenses) {
        setTeleTime(teleTime);
        setSurfFlow(surfFlow);
        setExpenses(expenses);
    }

    public int getTeleTime() {
        return teleTime;
    }

    public void setTeleTime(int teleTime) {
        this.teleTime = teleTime;
    }

    public int getSurfFlow() {
        return surfFlow;
    }

    public void setSurfFlow(int surfFlow) {
        this.surfFlow = surfFlow;
    }

    public int getExpenses() {
        return expenses;
    }

    public void setExpenses(int expenses) {
        this.expenses = expenses;
    }

    //通话时长，上网流量 只能依顺序进行，确保账户扣款准确性
    //1.接到普通通话类传过来的参数，根据手机卡情况统计消费时长，打印账户余额。
    //如果账户中通话时长为0就是初始通话调用if中语句，如果账户通话时长大于0就是历史通话调用else
    public void countTeleTime(int quantity, int expenses, PhoneCard phoneCard){
        //统计通话时长
        if(0 == phoneCard.getTeleTime()){
            phoneCard.setTeleTime(quantity);  //初次通话时间
        }else{
            setTeleTime(phoneCard.getTeleTime() + quantity);
            phoneCard.setTeleTime(getTeleTime()); //登记历史通话时间
        }
        phoneCard.setAccountBalance(phoneCard.getAccountBalance() - (quantity * expenses));
        System.out.println("----------历史通话时间-------------");
        System.out.println("历史通话时间：" + phoneCard.getTeleTime() + "分钟，账户余额" + phoneCard.getAccountBalance() + "元");
    }

    //2.接收普通上网类传过来的参数，根据手机卡情况统计上网情况，
    public void countSurfFlow(int quantity, int expenses, PhoneCard phoneCard){
        //统计上网流量
        if(0 == phoneCard.getSurfFlow()){
           phoneCard.setSurfFlow(quantity);  //初次登记历史通话时间
        }else{
            setSurfFlow(phoneCard.getSurfFlow() + quantity);
            phoneCard.setSurfFlow(getSurfFlow());
        }
        phoneCard.setAccountBalance(phoneCard.getAccountBalance() - (quantity * expenses));
        System.out.println("----------历史流量使用情况------------");
        System.out.println("历史流量使用情况：" + phoneCard.getSurfFlow() + "GB，账户余额" + phoneCard.getAccountBalance() + "元");
    }

}
